VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Create directory more than one level deep, such as C:\Windows\MyApp\Files. Returns True if succeede

by Bouke (1 Submission)
Category: Files/File Controls/Input/Output
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Sun 26th December 1999
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Create directory more than one level deep, such as C:\Windows\MyApp\Files. Returns True if succeeded or False if failed creating directory.

Rate Create directory more than one level deep, such as C:\Windows\MyApp\Files. Returns True if succeede



On Error Resume Next
    Dim bytMax As Byte
    Dim bytNdx As Byte
    Dim strDirLevel As String
    If Right(strDir, 1) <> "\" Then
            strDir = strDir & "\"
    End If
    bytMax = Len(strDir)
    For bytNdx = 4 To bytMax
        If (Mid(strDir, bytNdx, 1) = "\") Then
            strDirLevel = Left(strDir, bytNdx - 1)
            If Dir(strDirLevel, vbDirectory) = "" Then
                MkDir strDirLevel
            End If
        End If
    Next
    If Dir(strDir, vbDirectory) <> "" Then
        CreateDir = True ' Succeeded creating directory
    Else
        CreateDir = False ' Failed creating directory
    End If
End Function

Download this snippet    Add to My Saved Code

Create directory more than one level deep, such as C:\Windows\MyApp\Files. Returns True if succeede Comments

No comments have been posted about Create directory more than one level deep, such as C:\Windows\MyApp\Files. Returns True if succeede. Why not be the first to post a comment about Create directory more than one level deep, such as C:\Windows\MyApp\Files. Returns True if succeede.

Post your comment

Subject:
Message:
0/1000 characters